package roborally.Pieces;

import be.kuleuven.cs.som.annotate.*;

/**
 * This is a class representing a Game Piece without an Orientation, like a Battery or Wall.
 * @invar The position is valid 
 * 		| Position.isValidPosition(getPosition().getX(), getPosition().getY(), getPosition().getBoard() )
 * @version 2.0
 * @author Bart Opsomer 2de Bachelor Ingenieurswetenschappen Electrotechniek-Computerwetenschappen 
 * 		   Peter Opsomer 1ste Master Wiskundige IngenieursTechnieken
 */
public abstract class GamePieceWithoutOrientation extends GamePiece {

	protected Position position;
	/**
	 * Creates a GamePieceWithoutOrientation without a Position. No constructor public GamePiece(Position position) is
	 * given: use setPosition for this.
	 * @effect| super()
	 * @post  | new.getPosition() == null
	 */
	@Raw @Model
	protected GamePieceWithoutOrientation() {
		super();
		position = null;
	}
	/**
	 * @return the Position of this GamePieceWithOrientation
	 */
	@Basic @Override
	public Position getPosition() {
		return position;
	}
	/**
	 * Should be used with care: no other classes should directly set the position, but this method is needed in 
	 * Robot.move and RoboRally.putWall, Facade.pickUp or Wall.place, so this method cannot be protected or package accessible. 
	 * If the given Position is null, then the GamePieceWithOrientation is moved off the Board, but the Board should be notified.
	 * 
	 * @param position the new Position of this GamePieceWithoutOrientation, may be null
	 * @post | new.getPosition() == position
	 * @throws IllegalArgumentException
	 * 		| !isValidPosition(position)
	 */
	public void setPosition(Position position) {
	 	if (!isValidPosition(position) )
			throw new IllegalArgumentException("Position out of range.");
		this.position = position;
	}
}
